home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / dev / gcc / gcc270_src.lha / gcc-2.7.0-amiga / config / i386 / svr3gas.h < prev    next >
C/C++ Source or Header  |  1995-06-15  |  10KB  |  306 lines

  1. /* Definitions for Intel 386 running system V, using gas.
  2.    Copyright (C) 1992 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21. #include "i386/gas.h"
  22.  
  23. /* Add stuff that normally comes from i386/sysv3.h */
  24.  
  25. /* longjmp may fail to restore the registers if called from the same
  26.    function that called setjmp.  To compensate, the compiler avoids
  27.    putting variables in registers in functions that use both setjmp
  28.    and longjmp.  */
  29.  
  30. #define NON_SAVING_SETJMP \
  31.   (current_function_calls_setjmp && current_function_calls_longjmp)
  32.  
  33. /* longjmp may fail to restore the stack pointer if the saved frame
  34.    pointer is the same as the caller's frame pointer.  Requiring a frame
  35.    pointer in any function that calls setjmp or longjmp avoids this
  36.    problem, unless setjmp and longjmp are called from the same function.
  37.    Since a frame pointer will be required in such a function, it is OK
  38.    that the stack pointer is not restored.  */
  39.  
  40. #undef FRAME_POINTER_REQUIRED
  41. #define FRAME_POINTER_REQUIRED \
  42.   (current_function_calls_setjmp || current_function_calls_longjmp)
  43.  
  44. /* Modify ASM_OUTPUT_LOCAL slightly to test -msvr3-shlib, adapted to gas  */
  45. #undef ASM_OUTPUT_LOCAL
  46. #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)    \
  47.   do {                            \
  48.     int align = exact_log2 (ROUNDED);            \
  49.     if (align > 2) align = 2;                \
  50.     if (TARGET_SVR3_SHLIB)                \
  51.       {                            \
  52.     data_section ();                \
  53.     ASM_OUTPUT_ALIGN ((FILE), align == -1 ? 2 : align); \
  54.     ASM_OUTPUT_LABEL ((FILE), (NAME));        \
  55.     fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED));    \
  56.       }                            \
  57.     else                        \
  58.       {                            \
  59.     fputs (".lcomm ", (FILE));            \
  60.     assemble_name ((FILE), (NAME));            \
  61.     fprintf ((FILE), ",%u\n", (ROUNDED));        \
  62.       }                            \
  63.   } while (0)
  64.  
  65. /* Add stuff that normally comes from i386/sysv3.h via svr3.h */
  66.  
  67. /* Define the actual types of some ANSI-mandated types.  These
  68.    definitions should work for most SVR3 systems.  */
  69.  
  70. #undef SIZE_TYPE
  71. #define SIZE_TYPE "unsigned int"
  72.  
  73. #undef PTRDIFF_TYPE
  74. #define PTRDIFF_TYPE "int"
  75.  
  76. #undef WCHAR_TYPE
  77. #define WCHAR_TYPE "long int"
  78.  
  79. #undef WCHAR_TYPE_SIZE
  80. #define WCHAR_TYPE_SIZE BITS_PER_WORD
  81.  
  82. /* ??? This stuff is copied from config/svr3.h.  In the future,
  83.    this file should be rewritten to include config/svr3.h
  84.    and override what isn't right.  */
  85.  
  86. /* Support const sections and the ctors and dtors sections for g++.
  87.    Note that there appears to be two different ways to support const
  88.    sections at the moment.  You can either #define the symbol
  89.    READONLY_DATA_SECTION (giving it some code which switches to the
  90.    readonly data section) or else you can #define the symbols
  91.    EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
  92.    SELECT_RTX_SECTION.  We do both here just to be on the safe side.
  93.    However, use of the const section is turned off by default
  94.    unless the specific tm.h file turns it on by defining
  95.    USE_CONST_SECTION as 1.  */
  96.  
  97. /* Define a few machine-specific details of the implementation of
  98.    constructors.
  99.  
  100.    The __CTORS_LIST__ goes in the .init section.  Define CTOR_LIST_BEGIN
  101.    and CTOR_LIST_END to contribute to the .init section an instruction to
  102.    push a word containing 0 (or some equivalent of that).
  103.  
  104.    Define ASM_OUTPUT_CONSTRUCTOR to push the address of the constructor.  */
  105.  
  106. #define USE_CONST_SECTION    0
  107.  
  108. #define INIT_SECTION_ASM_OP     ".section\t.init"
  109. #define FINI_SECTION_ASM_OP     ".section .fini,\"x\""
  110. #define CONST_SECTION_ASM_OP    ".section\t.rodata, \"x\""
  111. #define CTORS_SECTION_ASM_OP    INIT_SECTION_ASM_OP
  112. #define DTORS_SECTION_ASM_OP    FINI_SECTION_ASM_OP
  113.  
  114. /* CTOR_LIST_BEGIN and CTOR_LIST_END are machine-dependent
  115.    because they push on the stack.  */
  116.  
  117. #ifdef STACK_GROWS_DOWNWARD
  118.  
  119. /* Constructor list on stack is in reverse order.  Go to the end of the
  120.    list and go backwards to call constructors in the right order.  */
  121. #define DO_GLOBAL_CTORS_BODY                    \
  122. do {                                \
  123.   func_ptr *p, *beg = alloca (0);                \
  124.   for (p = beg; *p; p++)                    \
  125.     ;                                \
  126.   while (p != beg)                        \
  127.     (*--p) ();                            \
  128. } while (0)
  129.  
  130. #else
  131.  
  132. /* Constructor list on stack is in correct order.  Just call them.  */
  133. #define DO_GLOBAL_CTORS_BODY                    \
  134. do {                                \
  135.   func_ptr *p, *beg = alloca (0);                \
  136.   for (p = beg; *p; )                        \
  137.     (*p++) ();                            \
  138. } while (0)
  139.  
  140. #endif /* STACK_GROWS_DOWNWARD */
  141.  
  142. /* Add extra sections .init and .fini, in addition to .bss from att386.h. */
  143.  
  144. #undef EXTRA_SECTIONS
  145. #define EXTRA_SECTIONS in_const, in_bss, in_init, in_fini
  146.  
  147. #undef EXTRA_SECTION_FUNCTIONS
  148. #define EXTRA_SECTION_FUNCTIONS                    \
  149.   CONST_SECTION_FUNCTION                    \
  150.   BSS_SECTION_FUNCTION                        \
  151.   INIT_SECTION_FUNCTION                        \
  152.   FINI_SECTION_FUNCTION
  153.  
  154. #define BSS_SECTION_FUNCTION                    \
  155. void                                \
  156. bss_section ()                            \
  157. {                                \
  158.   if (in_section != in_bss)                    \
  159.     {                                \
  160.       fprintf (asm_out_file, "\t%s\n", BSS_SECTION_ASM_OP);    \
  161.       in_section = in_bss;                    \
  162.     }                                \
  163. }
  164.  
  165. #define INIT_SECTION_FUNCTION                    \
  166. void                                \
  167. init_section ()                            \
  168. {                                \
  169.   if (in_section != in_init)                    \
  170.     {                                \
  171.       fprintf (asm_out_file, "\t%s\n", INIT_SECTION_ASM_OP);    \
  172.       in_section = in_init;                    \
  173.     }                                \
  174. }
  175.  
  176. #define FINI_SECTION_FUNCTION                    \
  177. void                                \
  178. fini_section ()                            \
  179. {                                \
  180.   if (in_section != in_fini)                    \
  181.     {                                \
  182.       fprintf (asm_out_file, "\t%s\n", FINI_SECTION_ASM_OP);    \
  183.       in_section = in_fini;                    \
  184.     }                                \
  185. }
  186.  
  187. #define READONLY_DATA_SECTION() const_section ()
  188.  
  189. #define CONST_SECTION_FUNCTION                        \
  190. void                                    \
  191. const_section ()                            \
  192. {                                    \
  193.   extern void text_section();                        \
  194.   if (!USE_CONST_SECTION)                        \
  195.     text_section();                            \
  196.   else if (in_section != in_const)                    \
  197.     {                                    \
  198.       fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);        \
  199.       in_section = in_const;                        \
  200.     }                                    \
  201. }
  202.  
  203. /* The ctors and dtors sections are not normally put into use 
  204.    by EXTRA_SECTIONS and EXTRA_SECTION_FUNCTIONS as defined in svr3.h,
  205.    but it can't hurt to define these macros for whatever systems use them.  */
  206. #define CTORS_SECTION_FUNCTION                        \
  207. void                                    \
  208. ctors_section ()                            \
  209. {                                    \
  210.   if (in_section != in_ctors)                        \
  211.     {                                    \
  212.       fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);        \
  213.       in_section = in_ctors;                        \
  214.     }                                    \
  215. }
  216.  
  217. #define DTORS_SECTION_FUNCTION                        \
  218. void                                    \
  219. dtors_section ()                            \
  220. {                                    \
  221.   if (in_section != in_dtors)                        \
  222.     {                                    \
  223.       fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);        \
  224.       in_section = in_dtors;                        \
  225.     }                                    \
  226. }
  227.  
  228. /* This is machine-dependent
  229.    because it needs to push something on the stack.  */
  230. #undef ASM_OUTPUT_CONSTRUCTOR
  231.  
  232. /* A C statement (sans semicolon) to output an element in the table of
  233.    global destructors.  */
  234. #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                       \
  235.   do {                                    \
  236.     fini_section ();                                   \
  237.     fprintf (FILE, "%s\t ", ASM_LONG);                    \
  238.     assemble_name (FILE, NAME);                              \
  239.     fprintf (FILE, "\n");                        \
  240.   } while (0)
  241.  
  242. /* A C statement or statements to switch to the appropriate
  243.    section for output of DECL.  DECL is either a `VAR_DECL' node
  244.    or a constant of some sort.  RELOC indicates whether forming
  245.    the initial value of DECL requires link-time relocations.  */
  246.  
  247. #define SELECT_SECTION(DECL,RELOC)                    \
  248. {                                    \
  249.   if (TREE_CODE (DECL) == STRING_CST)                    \
  250.     {                                    \
  251.       if (! flag_writable_strings)                    \
  252.     const_section ();                        \
  253.       else                                \
  254.     data_section ();                        \
  255.     }                                    \
  256.   else if (TREE_CODE (DECL) == VAR_DECL)                \
  257.     {                                    \
  258.       if ((0 && RELOC)    /* should be (flag_pic && RELOC) */        \
  259.       || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)        \
  260.       || !DECL_INITIAL (DECL)                    \
  261.       || (DECL_INITIAL (DECL) != error_mark_node             \
  262.           && !TREE_CONSTANT (DECL_INITIAL (DECL))))            \
  263.     data_section ();                        \
  264.       else                                \
  265.     const_section ();                        \
  266.     }                                    \
  267.   else                                    \
  268.     const_section ();                            \
  269. }
  270.  
  271. /* A C statement or statements to switch to the appropriate
  272.    section for output of RTX in mode MODE.  RTX is some kind
  273.    of constant in RTL.  The argument MODE is redundant except
  274.    in the case of a `const_int' rtx.  Currently, these always
  275.    go into the const section.  */
  276.  
  277. #define SELECT_RTX_SECTION(MODE,RTX) const_section()
  278.  
  279. /* This is copied from i386/sysv3.h.  */
  280.  
  281. /* Define a few machine-specific details of the implementation of
  282.    constructors.
  283.  
  284.    The __CTORS_LIST__ goes in the .init section.  Define CTOR_LIST_BEGIN
  285.    and CTOR_LIST_END to contribute to the .init section an instruction to
  286.    push a word containing 0 (or some equivalent of that).
  287.  
  288.    ASM_OUTPUT_CONSTRUCTOR should be defined to push the address of the
  289.    constructor.  */
  290.  
  291. #undef INIT_SECTION_ASM_OP
  292. #define INIT_SECTION_ASM_OP     ".section .init,\"x\""
  293.  
  294. #define CTOR_LIST_BEGIN                \
  295.   asm (INIT_SECTION_ASM_OP);            \
  296.   asm ("pushl $0")
  297. #define CTOR_LIST_END CTOR_LIST_BEGIN
  298.  
  299. #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)    \
  300.   do {                        \
  301.     init_section ();                \
  302.     fprintf (FILE, "\tpushl $");        \
  303.     assemble_name (FILE, NAME);            \
  304.     fprintf (FILE, "\n");            \
  305.   } while (0)
  306.